package controlller;

import java.net.URL;
import java.util.Iterator;
import java.util.ResourceBundle;

import bean.UserRow;
import fxManager.FXManager;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.TableView;
import javafx.scene.layout.AnchorPane;

public class MainController extends AnchorPane implements Initializable{
	@FXML private Button splitButton;
	@FXML private CheckBox batch;
	private boolean isSplit=false;
	private boolean batchFlag;
	public void initialize(URL url, ResourceBundle source) {
	}
	
	public void splitHandler(ActionEvent e) {
		if (!isSplit) {
			FXManager.getStage().setWidth(990);
			isSplit=true;
		}else {
			FXManager.getStage().setWidth(1500);
			isSplit=false;
		}
	}
	
	public void batchHandler(ActionEvent e) {
		TableViewController tableController=ControllerManager.getTable();
		TableView<UserRow> table=tableController.getTable();
		@SuppressWarnings("rawtypes")
		Iterator it=table.getItems().iterator();
		batchFlag=batch.isSelected();
		System.out.println();
		while(it.hasNext()) {
			UserRow user=(UserRow) it.next();
			user.getChoice().setSelected(batchFlag);
		}
	}
}
